package com.fengwk.cv4j.view.ind;

import org.nd4j.linalg.api.ndarray.INDArray;

import com.fengwk.support.exception.BaseException;

/**
 * 包装INDArray,使其兼容Number
 * 
 * @author fengwk
 *
 */
public class INDArrayWrap {

	/**
	 * INDArray
	 */
	private INDArray arr;
	
	/**
	 * Number
	 */
	private Number num;
	
	/**
	 * 使用INDArray构造
	 * 
	 * @param arr
	 */
	public INDArrayWrap(INDArray arr) {
		if (arr == null)
			throw new BaseException("arr == null");
		
		this.arr = arr;
	}
	
	/**
	 * 使用Number构造
	 * 
	 * @param num
	 */
	public INDArrayWrap(Number num) {
		if (num == null)
			throw new BaseException("num == null");
		
		this.num = num;
	}
	
	/**
	 * 获取INDArray
	 * 
	 * @return
	 */
	public INDArray arr() {
		return arr;
	}
	
	/**
	 * 获取Number
	 * 
	 * @return
	 */
	public Number num() {
		return num;
	}
	
	@Override
	public String toString() {
		if (arr != null)
			return arr.toString();
		return num.toString();
	}
	
}
